<?php 
function loop_list_post($atts, $content = null) {
    global $woo_options,$wp_rewrite;
     
    extract( shortcode_atts( array(	
        'post_type' => '',
        'orderby' => '',
        'order' => '',
        'taxonomy' => '',
        'term' => '',
        'posts_per_page' => -1,
        'paged' => 1
    ), $atts ) );
    
    
    $paged = (get_query_var('page')?get_query_var('page'):1);
    $query = array(
        'status' => array('publish','private'),
        'paged' => $paged
    );
    
    $query['post_type'] = isset($atts['post_type'])?$atts['post_type']:'post';
    
    if(!isset($atts['posts_per_page'])){
        $query['posts_per_page'] = (isset($woo_options['woo_postsperpage'])?$woo_options['woo_postsperpage']:10);
    }
    else{
        $query['posts_per_page'] = $atts['posts_per_page'];
    }
    
    $query['orderby'] = isset($atts['orderby'])?$atts['orderby']:"date";
    $query['order'] = isset($atts['order'])?$atts['order']:"asc";
    
    
    if(isset($atts['taxonomy']) && isset($atts['term'])){
        $query['tax_query'] = array(
            array(
                'taxonomy' => $atts['taxonomy'],
                'field' => 'slug',
                'terms' => $atts['term']
            )
        );
    }
    
    $the_query = new WP_Query($query);
    
    ob_start();?>    
    <?php if($the_query->have_posts()) { ?>
    <ul class="list-post">
        <?php while($the_query->have_posts()) { $the_query->the_post(); ?>
        <li>
            <div class="post-list-item">
                <h3 class="title"><a href="<?php the_permalink()?>"><?php the_title();?></a></h3>
                <!-- Thumbnail -->
                <?php if(has_post_thumbnail()) {
                list($url,$width, $height,$icon) = wp_get_attachment_image_src(get_post_thumbnail_id(),"full");
                ?>
                <div class="post-thumb">
                    <a href="<?php the_permalink()?>" class="link-image">
                        <img src="<?php echo get_template_directory_uri();?>/functions/thumb.php?src=<?php echo $url;?>&w=160&h=150&zc=2&a=c" />  
                    </a>
                </div>                                  
                <?php }?>
                <div class="description">
                    <?php the_excerpt();?>
                </div>
                <div class="read-more fr"><a href="<?php the_permalink();?>">Xem chi tiết...</a></div>
                <div class="clearfix"></div>
            </div>
        </li>   
        <?php } ?> 
    <?php }?>
    </ul>
    <div class="clearfix"></div>
    <nav class="pagination">
     <?php echo paginate_links(array(
        'base' => $wp_rewrite->using_permalinks()?user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%', 'page' ):@add_query_arg('page','%#%'),
        'format' => '',
        'current' => $paged,
        'total' => $the_query->max_num_pages,
        'type' => 'list',
        'prev_text' => __( '&larr; Previous', 'woothemes' ), // Translate in WordPress. This is the default.
        'next_text' => __( 'Next &rarr;', 'woothemes' ), // Translate in WordPress. This is the default.
    ));?>
    </nav>
    <?php
    wp_reset_query();
    $content .= ob_get_clean();
    return $content;
}
add_shortcode("posts", "loop_list_post");

?>